﻿function LoadQQDiv() {
    var qqpop = $('#popup_box');
    var wholeFrom = $(document);
    var top = wholeFrom.height() - qqpop.height() - 40;
    var left = wholeFrom.width() - qqpop.width() - 50;
    qqpop.css("top", top);
    qqpop.css("left", left);
    $('#popup_box').fadeIn("slow");
    $("#container").css({ // this is just for style
        "opacity": "0.3"
    });
    setTimeout("UnloadQQDiv()", 10000);
}

function UnloadQQDiv() {
    $('#popup_box').fadeOut("slow");
    $("#container").css({ // this is just for style		
        "opacity": "1"
    });
}

function GetNotification() {
    $.ajax({
        url: '/Chat/_GetNotifications',
        type: 'POST',
        success: function (data) {
            if ($.isArray(data)) {
                if (data.length > 0) {
                    var content = $('#popup_content');
                    content.empty();
                    for (var i = 0; i < data.length; i++) {
                        var msg = data[i].Content.Message.substring(0, 10) + "<br/>";
                        content.append(msg);
                    }
                    LoadQQDiv();
                }
            }
        }
    });
}

function ExecuteNotification() {
    window.setInterval("GetNotification()", 60000);
}
